package cn.xy.ymcc.feign;

import cn.xy.ymcc.constants.YmccError;
import cn.xy.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserPhoneFeignClientfallback implements FallbackFactory<UserPhoneFeignClient> {
    @Override
    public UserPhoneFeignClient create(Throwable throwable) {
        return new UserPhoneFeignClient() {
            @Override
            public JSONResult loadByPhone(String mobile) {
                throwable.printStackTrace();
                return JSONResult.success(false).error(YmccError.USER_EXISTS.getMessage());
            }

            @Override
            public JSONResult get(Long id) {
                return JSONResult.success(false).error(YmccError.USER_EXISTS.getMessage());
            }

            @Override
            public JSONResult list() {
                return JSONResult.success(false).error("业务繁忙");
            }
        };
    }
}
